<template>
  <el-container class="el-container">
    <el-header>
      <div class="logo">
        <img src="~assets/img/logo2.png" />
        <span>电商后台管理系统</span>
      </div>
      <el-button type="danger" @click="logout">退出</el-button>
    </el-header>
    <!-- 页面主体区域 -->
    <el-container>
      <!-- 侧边栏区域 -->
      <aside-list :menuList="menuList" />
      <!-- 内容区域 -->
      <main-area />
    </el-container>
  </el-container>
</template>

<script>
// import { getMenuList } from 'network/home'
import AsideList from './childComps/AsideList.vue'
import MainArea from './childComps/MainArea.vue'

export default {
  components: { AsideList, MainArea },
  name: 'Home',
  data() {
    return {
      menuList: [],
    }
  },
  created() {
    this.getMenuList()
  },
  methods: {
    logout() {
      window.sessionStorage.clear()
      this.$router.push('/login')
    },
    async getMenuList() {
      const { data: res } = await this.$http.get('menus')
      // console.log(res)
      if (res.meta.status !== 200) {
        return this.$message.error(res.meta.msg)
      }
      this.menuList = res.data
    },
  },
}
</script>

<style scoped>
.el-container {
  height: 100%;
}
.el-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #a5c6cb;
  color: #fff;
  height: 70px;
  padding-left: 0;
}

.el-header .logo {
  display: flex;
  align-items: center;
  justify-content: space-around;
  font-size: 24px;
  width: 300px;
}
.logo img {
  width: 60px;
}
</style>
